<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<script>
    function f() {
        var yonghm = document.getElementById("yhm").value;
        var mim = document.getElementById("mm").value;
        var arr = document.getElementsByClassName("se");
        var sex;
        for (var i = 0; i < arr.length; i++) {
            if (arr[i].checked==true){
                sex = arr[i].value;
            }
        }
        var arrr = document.getElementsByTagName("tr");
        var a = 0;
        for (var i = 0; i < arrr.length; i++) {
            var vr = arrr[i].innerText.split("\t");
            a = vr[0];
        }
        var data = "<tr>";
        data+="<td>"+(a+1)+"</td><td>"+yonghm+"</td>\n" +
            "            <td>"+mim+"</td>\n" +
            "            <td>"+sex+"</td>";
        data+="</tr>";
            document.getElementById("bg").innerHTML+=data;


    }
</script>
<body>
    用户名:<input type="text" name="yhm" id="yhm"/><br/>
    密码:<input type="password" name="mm" id="mm"/><br/>
    性别:<input type="radio" name="sex" value="man" class="se">男
        <input type="radio" name="sex" value="womam" class="se">女<br/>
    <button onclick="f()">添加到表格</button><br>
    <table id="bg" border="1" cellspacing="1" cellpadding="1">
        <th>序号</th>
        <th>用户名</th>
        <th>密码</th>
        <th>性别</th>
        <tr>
            <td>1</td>
            <td>zhangsan</td>
            <td>123</td>
            <td>man</td>
        </tr>
    </table>
</body>
</html>